﻿//-----------------------------------------------------------------------
// <copyright file="BaseSOEPropertyPage.cs" company="WorldView Solutions Inc">
//     Copyright (c) WorldView Solutions Inc. This source is subject to the Microsoft Public License (Ms-PL). All other rights reserved.
// </copyright>
//-----------------------------------------------------------------------

// Original: Copyright 2010 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions at <your ArcGIS install location>/DeveloperKit10.0/userestrictions.txt.
// 

using System;

namespace WorldViewSolutions.ArcGISServer.ArcCatalog
{
    /// <summary>
    /// Class to simplify implementation of a custom SOE property page for ArcCatalog.  Abstracts away COM registration and members that
    /// are unnecessary in a custom property page implemenation.
    /// </summary>
    [System.Runtime.InteropServices.GuidAttribute("E8B48820-AD61-4699-9C18-9CCBE6940416")]
    public abstract class BaseSOEPropertyPage : ESRI.ArcGIS.Framework.IComPropertyPage, ESRI.ArcGIS.CatalogUI.IAGSSOEParameterPage
    {
        #region Component Category Registration

        // Automatically register with ArcCatalog as a component, use categories.exe -> 
        // AGS Extension Parameter Pages to view. 
        [System.Runtime.InteropServices.ComRegisterFunction()]
        static void RegisterFunction(String regKey)
        {
            Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(regKey.Substring(18) + "\\Implemented Categories\\" + "{A585A585-B58B-4560-80E3-87A411859379}");
        }

        [System.Runtime.InteropServices.ComUnregisterFunction()]
        static void UnregisterFunction(String regKey)
        {
            Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(regKey.Substring(18));
        }
        #endregion

        #region IComPropertyPage Members

        #region Abstract (Must Implement) Members - PageSite, Activate, Show, Hide

        public abstract ESRI.ArcGIS.Framework.IComPropertyPageSite PageSite { set; }

        public abstract int Activate();

        public abstract void Show();

        public abstract void Hide();

        #endregion

        #region Virtual (Overrideable) Methods - Height, Deactivate

        public virtual int Height
        {
            get
            {
                return 0;
            }
        }

        public virtual void Deactivate()
        {
        }

        #endregion

        #region Non-Overridable Members - Not Invoked by ArcCatalog

        public bool IsPageDirty
        {
            get
            {
                return false;
            }
        }

        public string Title
        {
            get
            {
                return null;
            }
            set
            {
            }
        }

        public int Priority
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }

        public string HelpFile
        {
            get
            {
                return null;
            }
        }

        public int Width
        {
            get
            {
                return 0;
            }
        }

        public void Apply()
        {
        }

        public void Cancel()
        {
        }

        public int get_HelpContextID(int controlID)
        {
            return 0;
        }

        public void SetObjects(ESRI.ArcGIS.esriSystem.ISet objects)
        {
        }

        public bool Applies(ESRI.ArcGIS.esriSystem.ISet objects)
        {
            return false;
        }

        #endregion

        #endregion

        #region IAGSSOEParameterPage2 Members - All must be implemented

        public abstract ESRI.ArcGIS.esriSystem.IPropertySet ServerObjectProperties { get; set; }

        public abstract ESRI.ArcGIS.esriSystem.IPropertySet ExtensionProperties { get; set; }

        public abstract string ServerObjectExtensionType { get; }

        public abstract string ServerObjectType { get; }

        #endregion
    }
}